package br.edu.ufcg.dsc.actions.library;

import org.apache.struts2.config.ParentPackage;
import org.apache.struts2.config.Result;
import org.apache.struts2.dispatcher.ServletDispatcherResult;

import br.edu.ufcg.dsc.domain.Library;
import br.edu.ufcg.dsc.services.LibraryService;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;

@Result(name = "success", type = ServletDispatcherResult.class, value = "/jsp/library/libraryDetails.jsp")
@ParentPackage(value = "myPackage")
public class DetailsLibraryAction extends ActionSupport implements
		ModelDriven<Library>, Preparable {

	private static final long serialVersionUID = 1L;
	private Library library;
	private String libName;

	public String getLibName() {
		return libName;
	}

	public void setLibName(String libName) {
		this.libName = libName;
	}

	@Override
	public String execute() {
		return SUCCESS;
	}

	public void prepare() {
		library = LibraryService.find(libName);
	}

	public Library getLibrary() {
		return library;
	}

	public void setLibrary(Library library) {
		this.library = library;
	}

	public Library getModel() {
		return library;
	}

}
